import {createRouter,createWebHashHistory} from "vue-router";

const router = createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:"/",
            redirect:"/home"
        },
        {
            path:"/home",
            name:"home",
            component:()=>import("@/pages/Home/index.vue")
        },
        {
            path:"/algo",
            name:"algo",
            component:()=>import("@/pages/Algorithm/index.vue")
        },{
            path:"/big_upload",
            name:"bigUpload",
            component:()=>import("@/pages/BigUpload/index.vue")
        },{
            path:"/socket",
            name:"socket",
            component:()=>import("@/pages/Socket/index.vue")
        },{
            path:"/login",
            name:"login",
            component:()=>import("@/pages/Auth/login.vue"),
            meta:{
                title:"用户登录"
            }
        },,{
            path:"/register",
            name:"register",
            component:()=>import("@/pages/Auth/register.vue"),
            meta:{
                title:"用户注册"
            }
        },{
            path:"/chat",
            name:"chat",
            component:()=>import("@/pages/Chat/index.vue"),
            meta:{
                title:"聊天界面"
            }
        }
        ,{
            path:"/study",
            name:"study",
            component:()=>import("@/pages/Study/index.vue"),
            meta:{
                title:"Test-Study"
            }
        }
    ]
})

router.beforeEach((to,from,next)=>{
    console.log(to,"路由地址....")
    if(to.meta && to.meta.title){
        document.title = to.meta.title;
    }else{
        document.title = "知识平台";
    }

    next();
})

export default router;